package samples.d2.lines 
{
	import flash.filters.GlowFilter;
	import flash.geom.Rectangle;
	import flash.utils.setInterval;
	import samples.BaseSample;
	import shapes.shapes2D.Dot;
	import shapes.shapes2D.Line;
	
	/**
	 * @author Nicolas Barradeau
	 * http://en.nicoptere.net
	 */
	public class _Line1 extends BaseSample
	{
		
		private var d0:Dot;
		private var d1:Dot;
		
		private var d2:Dot;
		private var d3:Dot;
		
		private var line0:Line;
		private var line1:Line;
		
		private var angle:Number = 0;
		
		public function _Line1() 
		{
			
			//filters = [new GlowFilter( color, 1, 12, 12, 2, 3 ) ];
			
			var oy:int = 60;
			d0 = new Dot( 100, sh / 2 - oy );
			d1 = new Dot( sw - 100, sh / 2 - oy );
			
			d2 = new Dot( 100, sh / 2 + oy );
			d3 = new Dot( sw - 100, sh / 2 + oy );
			
			line0 = new Line( d0, d1 );
			line1 = new Line( d2, d3 );
			
			render();
			
			interval = setInterval( update, 30 );
			
		}
		
		private function update():void
		{
			
			
			d0.y = sh / 2 - 60 + Math.sin( angle ) * 50;
			d1.x = sw / 2 - 60 + Math.cos( angle ) * 50;
			d2.x = sw / 2 + 60 + Math.cos( angle ) * 50;
			d3.y = sh / 2 + 60 + Math.sin( angle ) * 50;
			
			angle += Math.PI / 180;
			render();
		}
		
		private function render():void
		{
			graphics.clear();
			
			
			graphics.lineStyle( 0, color );
			
			d0.draw( graphics );
			d1.draw( graphics );
			d2.draw( graphics );
			d3.draw( graphics );
			
			line0.draw( graphics );
			line1.draw( graphics );
			
			graphics.endFill();
			
			graphics.lineStyle( 2, 0xFF0000 );
			var rect:Rectangle = this.getBounds( _stage );
			//graphics.drawRect( rect.x, rect.y, rect.width, rect.height );
		}
		
	}

}